#!/usr/bin/env sh

if [[ "${SKIP_INTEGRATION_TEST_REPO}" ]]; then
  echo "\033[41m Skip integration testing."
  exit 0;
fi


if [[ -z "${REMAX_INTEGRATION_TEST_REPO}" ]]; then
  echo "请先设置环境变量 REMAX_INTEGRATION_TEST_REPO"
  exit 1
fi

TEST_DIR=integration-test

# clone 集成测试
if [ -d "$TEST_DIR" ]; then
  echo "Updating ${TEST_DIR}..."
  cd $TEST_DIR
  git pull
  cd ..
else
  echo "Cloing ${TEST_DIR}..."
  git clone $REMAX_INTEGRATION_TEST_REPO $TEST_DIR
fi
cd $TEST_DIR
ayarn
yarn link remax @remax/cli @remax/ali @remax/runtime
yarn build
yarn test
